-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Fix failed sub-asset loads getting stuck in LoadState::Loading
#22628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… least for the case where the sub-asset type is known.
…t is not of the requested type.
… requested type".
…a `AssetLoadError` variant.
…d was requested on the sub-asset. This meant the `LoadStatus` of the sub-asset would not reflect the error.
| for _ in 0..LARGE_ITERATION_COUNT { | ||
| app.update(); | ||
| load_state = asset_server.get_load_state(&handle).unwrap().into(); | ||
| if load_state == expected_load_state { | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just use run_app_until here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this initially, but found that it made debugging test failures harder - run_app_until will panic without any information about what failed. Doing it manually lets me print a clear "did X, expected Y, got Z".
I do think there's room for improvement. Maybe adding a run_app_until variant with more options, or even better a way to say "run until all loads have resolved". But don't think that would fit in this PR.
Objective
Fix #22607. Also add a test that reproduces the issues.
If it makes things clearer, I can split this into an "add a test" PR and a separate "fix the bug" PR.
Solution
There are three additions to
AssetServer::load_internalthat each fix a separate case. In source code order:Case 1
Previously this would silently fail - the asset would successfully load, but the handle can't actually resolve to that asset so it's stuck in limbo.
Fixed by adding a type check, then sending a
AssetLoadError::RequestedHandleTypeMismatchevent and returning it as an error.Note that this doesn't prevent someone loading the asset with the correct type - the error is only associated with the
<WrongAssetType>handle.Case 2
Previously this was detected and would return a
AssetLoadError::MissingLabelerror fromload_internal, but the load status for the handle wasn't set.Fixed by sending an
InternalAssetEvent::Failed.Case 3
Previously this was detected, but the event was sent with the root asset's id (
base_asset_id) so it wasn't associated with the sub-asset's handle.Fixed by using the sub-asset's id.
Notes
Some of the events are only sent if
asset_idis set. This might seem odd, but I think it's correct -asset_idcan only be unset when usingload_untypedwith a sub-asset path, in which case there's no handle to associate with the error, and so there's no handle to pass toget_load_status.Testing